#@layout()

#define css()

<!--全局样式-->
<style type="text/css">
    #bazaar {
        background-image: url(http://47.105.208.60:8080/wechat-api/images/loginbg.png);
        background-position: center center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
    }

    form#index {
        margin-left: auto;
        margin-right: auto;
        max-width: 500px;
        background: #F7F7F7;
        opacity: 0.95;
        padding: 25px 15px 25px 10px;
        font: 12px Georgia, "Times New Roman", Times, serif;
        color: #888;
        text-shadow: 1px 1px 1px #FFF;
        border: 1px solid #E4E4E4;
        text-align: center;
    }

    form#index h3 {
        font-size: 25px;
        padding: 0px 0px 10px 40px;
        display: block;
        border-bottom: 1px solid #E4E4E4;
        margin: -10px -15px 30px -10px;;
        color: #888;
        text-align: center;
    }

    form#index label {
        display: block;
        margin: 0px;
    }

    form#index label > span {
        float: left;
        width: 20%;
        text-align: right;
        padding-right: 10px;
        margin-top: 10px;
        color: #888;
    }

    form#index input[type="text"], form#index input[type="number"] {
        border: 1px solid #DADADA;
        color: #888;
        height: 30px;
        margin-bottom: 16px;
        margin-right: 6px;
        margin-top: 2px;
        outline: 0 none;
        padding: 3px 3px 3px 5px;
        width: 70%;
        font-size: 12px;
        line-height: 15px;
        box-shadow: inset 0px 1px 4px #ECECEC;
        -moz-box-shadow: inset 0px 1px 4px #ECECEC;
        -webkit-box-shadow: inset 0px 1px 4px #ECECEC;
    }

    form#index .button {
        background: #E27575;
        border: none;
        padding: 10px 25px 10px 25px;
        color: #FFF;
        box-shadow: 1px 1px 5px #B6B6B6;
        border-radius: 3px;
        text-shadow: 1px 1px 1px #9E3F3F;
        cursor: pointer;
    }

    form#index label .container {
        width: 300px;
        height: 30px;
        background-color: greenyellow;
        margin-left: auto;
        margin-right: auto;

    }

    form#index label > span #progress {
        height: 20px;
        background-color: darkgray;
        display: inline-block;
        padding: 3px 0 0 0;
    }

</style>
#end

#define script()

<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>

<script type="text/javascript" src="js/jquery.serializejson.min.js"></script>
<script>
    function onLoadByPage() {
        var id = "#(id ??)" //getQueryParameter('id')//获取id
        //后台查询数据
        console.log("+++++++++" + id + "asdasd")

        var url="http://47.105.208.60:8080/wechat-api/douyin/findById?id=" + id;
        //var url = "http://localhost:8080/wechat-api/douyin/findById?id=" + id;

        //post方式传送的数据
        var objData =
            [
                {name: 'id', value: id}
            ];

        $.ajax({
            url: url,
            data: objData,
            //dataType: 'json',
            type: 'POST',
            success: function (data) {
                if (data.code == 0) {
                    var msg = data.info;
                    console.log("+++++++++")
                    console.log(data)
                    document.getElementById("id").value = msg.id;
                    document.getElementById("eid").value = msg.eid;
                    document.getElementById("name").value = msg.name;
                    document.getElementById("address").value = msg.address;
                    document.getElementById("longitude").value = msg.longitude;
                    document.getElementById("latitude").value = msg.latitude;

                    console.log(msg.etype);
                    $('input:checkbox').each(function (index, domEle) {
                        console.log(domEle)
                        var inputclients = domEle.value;
                        var clients = data.etype.split(",");
                        console.log(inputclients + "111")

                        for (var j = 0; j < clients.length; j++) {
                            if (inputclients == clients[j]) {
                                console.log(clients[j] + "22222");

                                domEle.checked = true;
                            }
                        }

                    });

                    document.getElementById("summary").value = msg.summary;
                    document.getElementById("report").value = msg.report;
                    document.getElementById("username").value = msg.username;
                    document.getElementById("userphone").value = msg.userphone;
                }

            }, error: function (err) {
                console.log("----------")
                console.log(err)
            }
        });

    }

    onLoadByPage();

    //保存抖音线路
    $("form").submit(function(){
        var obj = document.getElementsByName("etype");
        var val = [];
        for (var k = 0; k < obj.length; k++) {
            if (obj[k].checked) {
                val.push(obj[k].value)
            }
        }
        console.log(val)

        var eee = val.join(',');

        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/product/updateProductSite",
            //url: "http://localhost:8080/wechat-api/product/updateProductSite",
            data: $("form").serialize(),
                //JSON.stringify(array),

            //JSON.stringify($('#index').serializeJSON()),

            type: 'POST',
            dataType: "json",
            //contentType: "application/json",
            success: function (data) {
                if (data.code == 0) {
                    console.log("+++++++++");
                    console.log(data.info);
                    alert("提交成功");
                    document.getElementById("index").reset();

                    window.location.href = "index1";
                } else {
                    console.log("----------");
                    console.log();
                    alert("提交失败");
                }

            }, error: function (data) {
                alert(data.msg);
            }
        });
    })


</script>
#end

<!--</head>
<body>-->
#define content()
<div id="bazaar" class="content-wrapper">
    <form id="index" onsubmit="return false" action="##" method="post">
        <h3 style="align-content: center">淘山货大市信息修改</h3>
        <label>
            <input type="text" name="id" class="id" id="id" style="display: none">
        </label>
        <label>
            <span>地理编号:</span>
            <input type="text" name="eid" class="eid" id="eid">
        </label>
        <label>
            <span>地理名称:</span>
            <input type="text" name="name" class="name" id="name">
        </label>
        <label>
            <span>地理地址:</span>
            <input type="text" name="address" class="address" id="address">
        </label>
        <label>
            <span>经度:</span>
            <input type="text" name="longitude" class="longitude" id="longitude">
        </label>
        <label>
            <span>纬度:</span>
            <input type="text" name="latitude" class="latitude" id="latitude">
        </label>
        <!--<label>
            <span>类型:</span>
            <input type="radio" name="etype" value="万市抖音路线" id="etype1">万市抖音路线
            <input type="radio" name="etype" value="洞桥抖音路线" id="etype2">洞桥抖音路线
            <input type="radio" name="etype" value="胥口抖音路线" id="etype3">胥口抖音路线
            <input type="radio" name="etype" value="新登抖音路线" id="etype4">新登抖音路线
        </label>--><br>
        <label>
            <span>简介:</span>
            <input type="text" name="summary" class="summary" id="summary">
        </label>

        <label>
            <span>上报人:</span>
            <input type="text" name="report" class="report" id="report">
        </label>
        <label>
            <span>联系人: </span>
            <input type="text" name="username" class="username" id="username">
        </label>
        <label>
            <span>联系电话:</span>
            <input type="number" name="userphone" class="userphone" id="userphone">
        </label>

        <input type="submit" class="button" value="保存">&nbsp;&nbsp;&nbsp;


    </form>
</div>
#end
